<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<script type="text/javascript">
	$(function() {
		$("#user_setRole_ok").click(function() {
			var userId = $("#user_setRole_userId").val();
			var roleOpts = $("option[title='temp']");
			var roleIds = "";

			for ( var i = 0; i < roleOpts.length; i++) {
				if (roleOpts[i].selected == true) {
					roleIds += roleOpts[i].value + ",";
				}
			}

			roleIds = roleIds.substr(0, roleIds.length - 1);

			$.post("user/setRoles", {userId : userId,roleIds : roleIds}, function(data) {
				$("#user_edit_dialog").dialog("close");
			});
		});

		$("#user_setRole_cancel").click(function() {
			$("#user_edit_dialog").dialog("close");
		});
	});
</script>

<input id="user_setRole_userId" type="hidden" name="id" value="${userId }"/>
<select name="roles" id='liOption' multiple='multiple' size='8' style="width:300px; margin-left: 22px">
	<c:forEach var="role" items="${roles }">
		<option title='temp' <c:if test="${role.selected }">selected='selected'</c:if>
			value="${role.id }">${role.roleName }</option>
	</c:forEach>
</select>

<br/><br/><br/>
<a id="user_setRole_ok" class="easyui-linkbutton"
	data-options="iconCls:'icon-ok'">确定</a>
<a id="user_setRole_cancel" class="easyui-linkbutton"
	data-options="iconCls:'icon-cancel'">取消</a>